<template>
	<view class="box-detail">
		<view class="item-index-top">
			<view class="item-top-text">项目再评估</view>
		</view>
		<view class="box-detail-content" v-if="!sendDataList.length">
			<view class="box-detail-content-item">
				<view class="row-title">进入评估日期</view>
				<view class="row-content">无</view>
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">人员</view>
				<view class="row-content">无</view>
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">状态</view>
				<view class="row-content">无</view>
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">评估意见</view>
				<view class="row-content">无</view>
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">备注</view>
				<view class="row-content">无</view>
			</view>
			<view class="box-attach">
				<view class="box-attach-title">评估附件</view>
				<view class="box-attach-row">
					<view class="box-attach-name">无</view>
				</view>
			</view>
			<view class="box-attach">
				<view class="box-attach-title">评估修正附件</view>
				<view class="box-attach-row">
					<view class="box-attach-name">无</view>
				</view>
			</view>
		</view>
		
		<view class="box-detail-content" v-for="item,index in sendDataList"  :key="index">
			<view class="box-detail-content-item">
				<view class="row-title">进入评估日期</view>
				<uni-datetime-picker class="form-picker" type="date" :value="item.EVALUATE_DATE" start="2020-6-15" end="2025-6-15" @change="dateChange(index,$event)"></uni-datetime-picker>
				<!-- <view class="row-content">{{item.EVALUATE_DATE||'无'}}</view> -->
			</view>
			<view class="box-detail-content-item" @tap="toPersonList(index)">
				<view class="row-title">人员</view>
				<textarea class="uni-input textarea-style" v-model="item.MEMBER_NAME" name="input" placeholder="请填写人员"/>
				<!-- <view class="row-content">{{item.MEMBER_NAME||'无'}}</view> -->
			</view>
			<view class="box-detail-content-item" >
				<view class="row-title">状态</view>
				<input class="uni-input form-input" v-model="item.STATUS_NAME" name="input" placeholder="请选择状态" @click="showSinglePicker(index)" disabled=""/>
				<!-- <view class="row-content">{{item.OPINION||'无'}}</view> -->
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">评估意见</view>
				<input class="uni-input form-input" v-model="item.OPINION" name="input" placeholder="请填写评估意见"/>
				<!-- <view class="row-content">{{item.OPINION||'无'}}</view> -->
			</view>
			<view class="box-detail-content-item">
				<view class="row-title">备注</view>
				<textarea class="uni-input textarea-style" v-model="item.REMARK" name="input" placeholder="请填写备注" />
				<!-- <view class="row-content">{{item.REMARK||'无'}}</view> -->
			</view>
			
			<view class="box-attach">
				<view class="box-attach-title">评估附件</view>
				<view class="box-attach-row">
					<view class="box-attach-icon" >
						<image src="../../../../static/images/icon_enclosure.png" mode=""></image>
					</view>
					<text class="box-attach-name" @click="uploadFiles()">点击上传</text>
				</view>
				<view class="box-attach-row"  v-for="item,index in item.file_PGFJ" :key="index">
					<view class="box-attach-icon" >
						<image src="../../../../static/images/icon_enclosure.png" mode=""></image>
					</view>
					<view class="box-attach-name">{{ item.fileShowName||"无"}}</view>
				</view>
			</view>
			<view class="box-attach">
				<view class="box-attach-title">评估修正附件</view>
				<view class="box-attach-row">
					<view class="box-attach-icon" >
						<image src="../../../../static/images/icon_enclosure.png" mode=""></image>
					</view>
					<text class="box-attach-name" @click="uploadFiles()">点击上传</text>
				</view>
				<view class="box-attach-row"  v-for="item,index in item.file_PGXGFJ" :key="index">
					<view class="box-attach-icon" >
						<image src="../../../../static/images/icon_enclosure.png" mode=""></image>
					</view>
					<view class="box-attach-name">{{ item.fileShowName||"无"}}</view>
				</view>
			</view>
			<view class="delete-item-work" @click="deleteItem(index)"></view>
		</view>
		<new-file ref="child" :pageData="pageData"/>
		<view class="add-box-detail-content border-wid" @click="addItem()"></view>
		<mpvue-picker :themeColor="themeColor" ref="mpvuePicker1" :mode="mode" :deepLength="deepLength" :pickerValueDefault="pickerValueDefault"
		 @onConfirm="onConfirm1" @onCancel="onCancel" :pickerValueArray="pickerValueArray"></mpvue-picker>
	</view>
</template>

<script>
	import newFile from './new_file.vue'
	import mpvuePicker from '@/components/mpvue-picker/mpvuePicker.vue';
	export default {
		components: {
		    mpvuePicker,
			newFile
		},
		data(){
			return{
				themeColor: '#007AFF',
				mode: '',
				deepLength: 1,
				pickerValueDefault: [3],
				pickerValueArray:[],
				code:'',
				sendDataList:[],
				getFileList:[],
				projectId:'',
				deleteList:[],
				activeIndex:0,
				fileListData:{}
			}
		},
		props: {
			pageData: {
				type: Object,
				default(){
					return {}
				}
			}
		},
		watch:{
			pageData(){
				if(this.pageData.dataGrid['bus_eval_view'].datas.length){
					console.log(this.pageData.dataGrid['bus_eval_view'].datas,"this.pageData.dataGrid['bus_eval_view'].datas")
					this.pageData.dataGrid['bus_eval_view'].datas.map(item=>{
						this.projectId=item.PROJ_ID
						this.sendDataList.push({
							datakey:item.DATAKEY,
							proid:item.PROJ_ID,
							EVALUATE_DATE:item.EVALUATE_DATE,//核查日期
							MEMBER:item.MEMBER,//人员code
							MEMBER_NAME:item.MEMBER_NAME,//人员name
							OPINION:item.OPINION,//核查意见
							STATUS: item.STATUS,
							STATUS_NAME: item.STATUS_NAME,
							REMARK:item.REMARK,//备注
							file_PGFJ:item.PGFJ,//项目分析报告
							file_PGXGFJ:item.PGXGFJ,//项目分析报告修正附件
							leixing:0,//操作类型
						})
					})
				}else{
					this.sendDataList=[]
				}	
			},
		},
		methods:{
			addItem(){
				this.sendDataList.push({
					datakey: this.getUUID(),
					proid:this.projectId,
					EVALUATE_DATE:'',//核查日期
					MEMBER:'',//人员code
					MEMBER_NAME:'',//人员name
					OPINION:'',//核查意见
					STATUS: '',
					REMARK:'',//备注
					file_PGFJ:[],//项目分析报告
					file_PGXGFJ:[],//项目分析报告修正附件
					leixing:1,//操作类型 //操作类型  新增行标记为1，删除行标记为3，修改行不处理保留原值0
				})
			},
			deleteItem(index){
				if(index===0&&this.sendDataList.length===1){
					this.sendDataList=[]
				}else{
					if(this.sendDataList[index].leixing===0){
						this.deleteList.push({
							datakey: this.sendDataList[index].datakey,
							proid:this.sendDataList[index].proid,
							EVALUATE_DATE:this.sendDataList[index].EVALUATE_DATE,//核查日期
							MEMBER:this.sendDataList[index].MEMBER,//人员code
							MEMBER_NAME:this.sendDataList[index].MEMBER_NAME,//人员name
							OPINION:this.sendDataList[index].OPINION,//核查意见
							STATUS: this.sendDataList[index].STATUS,
							REMARK:this.sendDataList[index].REMARK,//备注
							file_PGFJ:this.sendDataList[index].file_PGFJ,//项目分析报告
							file_PGXGFJ:this.sendDataList[index].file_PGXGFJ,//项目分析报告修正附件
							leixing:3, //操作类型  新增
						})
						this.sendDataList.splice(index,1)
					}else if(this.sendDataList[index].leixing===1){
						this.sendDataList.splice(index,1)
						
					}
				}	
			},
			dateChange(index,e) {
				this.sendDataList[index].EVALUATE_DATE=e
			},
			showSinglePicker(index) {
				console.log(index,'6666')
				this.activeIndex=index
				this.$refs.mpvuePicker1.show()
				let dataArry=[
					{
						label: '未评估',
						value: 0,
					},
					{
						label: '评估中',
						value: 1,
					},
					{
						label: '已评估',
						value: 2,
					},
				]
				this.pickerValueArray=dataArry
				this.mode = 'selector'
				this.deepLength = 1
				this.pickerValueDefault = [0]
				
			},
			onCancel(e) {
			    console.log(e)
			},
			onConfirm1(e) {
				if(this.sendDataList.length){
					this.sendDataList[this.activeIndex].STATUS_NAME=e.label
					this.sendDataList[this.activeIndex].STATUS=e.value[0]
				}
			},
			toPersonList(index) {
				this.$emit('getIndex',{dataList:this.sendDataList,index:index,num:8})
				uni.navigateTo({
					url: '../../selectList/person'
				})
			},
			getUUID() {
			   var s = [];
			   var hexDigits = "0123456789abcdef";
			   for (var i = 0; i < 36; i++) {
			    s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
			   }
			   s[14] = "4"; 
			   s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1); 
			   s[8] = s[13] = s[18] = s[23] = "";
			
			   var uuid = s.join("");
			   return uuid;
			},
			uploadFiles(){
				this.$refs.child.popOpen()
			}
		},
	}
</script>

<style lang="scss" scoped>
	.wrap{
		padding-bottom: 60rpx;
	}
	page{
		padding-bottom: 20rpx;
	}
	.box-detail {
		min-height: 760rpx;
		background-color: #ffffff;
		border-radius: 20rpx;
		margin: 20rpx;
		padding: 26rpx 30rpx 50rpx 30rpx;
	}
	.item-index-top{
		// width: 650rpx;
		height: 40rpx;
		// margin: 20rpx 20rpx 18rpx 20rpx;
		background-color: #0099cc;
		border-radius: 10rpx;
		.item-top-text{
			font-family: AlibabaPuHuiTi-Regular;
			padding-left: 20rpx;
			font-size: 26rpx;
			font-weight: normal;
			line-height: 40rpx;
			letter-spacing: 0px;
			color: #ffffff;
		}
	}
	.item-top{
		display: flex;
		justify-content: space-between;
		.setion-left{
			display: flex;
			flex-direction: column;
			.left-text-top{
				font-size: 30rpx;
				font-weight: 600;
				color: #414a5d;
			}
			.left-text-bot{
				margin-top: 22rpx;
				font-size: 26rpx;
				color: #7f7f7f;
			}
		}
		.setion-right{
			display: flex;
			flex-direction: column;
			align-items: flex-end;
			.right-text-top{
				height: 30rpx;
				line-height: 30rpx;
				font-size: 26rpx;
				font-weight: normal;
				color: #9a9a9a;
			}
			.right-text-bot{
				margin-top: 22rpx;
				font-size: 28rpx;
				font-weight: normal;
				color: #999999;
			}
		}
	}
	.box-detail-header {
		display: flex;
		justify-content: space-between;
		margin-bottom: 8rpx;
	
		.name {
			font-size: 30rpx;
			color: #414a5d;
			font-weight: bold;
		}
	
		.date {
			font-size: 26rpx;
			color: #9a9a9a;
		}
	}
	
	.box-net {
		font-size: 26rpx;
		color: #0099cc;
	}
	
	.box-detail-content {
		position: relative;
		margin-top: 24rpx;
		padding: 0 10rpx 20rpx 10rpx;
		border-bottom: 8rpx solid #e8f0f2;
		
	}
	// .border {
	// 	;
	// }
	.border-wid{
		border-bottom: 0
	}
	.box-detail-content-item {
		display: flex;
		flex-direction: row;
		// justify-content: flex-start;
		// justify-content: space-between;
		margin-bottom: 20rpx;
	
		.row-title {
			width: 170rpx;
			font-size: 26rpx;
			color: #9a9a9a;
			text-align: left;
			flex-shrink: 0;
			margin-right: 10rpx;
	
			&.mag {
				margin-left: 18rpx;
			}
		}
	
		.row-content {
			font-size: 26rpx;
			color: #414a5d;
			word-wrap: break-word;
			word-break: break-all;
			flex: 1;
			text-align: left;
	
			&.mag {
				margin-right: 18rpx;
			}
		}
	}
	
	.bar-contact {
		background-color: #0099cc;
		border-radius: 10px;
		height: 40rpx;
		line-height: 40rpx;
		padding-left: 18rpx;
		color: #FFFFFF;
		font-size: 24rpx;
		
	}
	.box-attach{
		margin-top: 20rpx;
		padding-top: 20rpx;
		// padding: 0 10rpx;
		border-top: 1px solid #e8f0f2;
	}
	.box-attach-row {
		display: flex;
		align-items: center;
		// padding: 0 18rpx;
		// height: 38rpx;
		margin-bottom: 10rpx;
		.box-attach-icon {
			width: 34rpx;
			margin-right: 30rpx;
		}
		.box-attach-name {
			font-size: 26rpx;
			color: #0099cc;
		}
	}
	.fixed-action-bar{
		width: 100%;
		display: flex;
		height: 70rpx;
		align-items: center;
		background: #fff;
		position: fixed;
		bottom: 0;
		left: 0;
		z-index: 999;
		.item{
			width: 50%;
			display: flex;
			justify-content: center;
			align-items: center;
			
		}
		.icon{
			width: 30rpx;
		}
		.btn-box{
			width: 90rpx;
			display: flex;
			align-items: center;
			justify-content: space-between;
			height: 70rpx;
		}
		.text-edit{
			font-size: 24rpx;
			color: #0099cc;
			line-height: 70rpx;
		}
		.text-delete{
			font-size: 24rpx;
			color: #cc3357;
			line-height: 70rpx;
		}
	}
	.box-attach-row {
		display: flex;
		align-items: center;
		padding: 0 18rpx;
		// height: 38rpx;
		margin-bottom: 10rpx;
		.box-attach-icon {
			width: 34rpx;
			margin-right: 30rpx;
		}
		.box-attach-name {
			font-size: 26rpx;
			color: #0099cc;
		}
	}
	.box-attach{
		margin-top: 20rpx;
		padding: 20rpx 0 0 0;
		border-top: 1px solid #e8f0f2;
	
		.box-attach-title{
			// width: 170rpx;
			font-size: 26rpx;
			color: #9a9a9a;
			text-align: left;
			flex-shrink: 0;
			// margin-bottom: 10rpx;
		}
		.box-attach-row {
			display: flex;
			justify-content: flex-start;
			// align-items: center;
			// padding: 0 18rpx;
			// height: 38rpx;
			margin: 10rpx 0;
			.box-attach-icon {
				width: 34rpx;
				height:40rpx;
				margin-right: 20rpx;
				// background-image: url(../../../../static/images/icon_enclosure.png);
				// box-sizing: 34rpx 40rpx;
				// background-repeat: no-repeat;
				image{
					width: 100%;
					height: 100%;
				}
			}
			.box-attach-name {
				flex: 1;
				font-size: 26rpx;
				color: #0099cc;
			}
		}
	}
	.add-box-detail-content{
		height: 90rpx;
		background-image: url(../../../../static/images/add.png);
		background-repeat: no-repeat;
		background-position: 50% 50%;
		background-size: 160rpx 46rpx;
		
	}
	.uni-input{
		font-size: 26rpx;
		color: #808080;
		// border-bottom:1px solid #dce4e6;
		flex:1;
	}
	.textarea-style{
		height:112rpx ;
	}
	.form-picker {
		width: 250rpx;
	}
	.delete-item-work{
		width:54rpx;
		height: 54rpx;
		background: url(../../../../static/images/icon_del.png);
		background-size:36rpx 36rpx ;
		background-repeat: no-repeat;
		background-position:18rpx 0;
		position: absolute;
		z-index: 100;
		top: 0;
		right: 0;
	}
</style>
